package org.om.service;

import org.om.dao.UserDao;
import org.om.excepion.BusinessException;
import org.om.model.Users;
import org.redkale.service.Service;
import org.redkale.util.AutoLoad;
import org.redkale.util.ResourceType;

import javax.annotation.Resource;
import java.util.logging.Logger;


/**
 * The type User service.
 *
 * @author :<a href="mailto:penggangshu@ebnew.com">舒彭钢</a>
 * @date :2016-07-01 15:06:41
 */

public class UserService implements Service{
    protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName());

    @Resource
    UserDao userDao;

    public boolean login(Users loginUser) throws BusinessException {
        Users fUser = userDao.getByLoginName(loginUser.getLoginName());
        if(fUser!=null){
            String fpwd =  fUser.getLoginPwd();
            if(fpwd.equals(loginUser.getLoginPwd())){
                return true;
            }else{
                throw new BusinessException("密码错误！");
            }
        }else{
            throw new BusinessException("没有该用户！");
        }
    }
}
